﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BZ.Common;
using BZ.Common.FileUtility;
using System.Threading;
using System.Runtime.Serialization.Json;
using System.IO;
using System.Runtime.Serialization;
using System.Web;
using System.Threading.Tasks;

namespace Test
{
    class Program
    {
        

        static void Main(string[] args)
        {
            Console.WriteLine(CommonUtility.GetWindowsServiceInstallPath("TeamViewer"));

            #region 正则超时处理测试
            //FileStream file1 = new FileStream("e:\\1.htm", FileMode.Open, FileAccess.Read);
            //StreamReader reader = new StreamReader(file1);

            //string html = reader.ReadToEnd();

            //bool istimeout =false ;

            //List<string> myLists = RegexUtility.GetPairTagInnerHtmls(html,out istimeout,"div","class", "godreply_on");

            //if (istimeout == false)
            //{

            //    foreach (string item in myLists)
            //    {
            //        Console.WriteLine(item);
            //    }
            //}
            //else
            //{
            //    Console.WriteLine("处理超时");
            //}
            #endregion

            #region 线程测试样例

            //string rsltA = string.Empty;
            //string rsltB = string.Empty;

            //CancellationTokenSource cts = new CancellationTokenSource();

            //Thread myA = new Thread(() =>
            //{
            //    threadtest.func("A:" + Thread.CurrentThread.ManagedThreadId.ToString());
            //    rsltA = threadtest.rslt;
            //});

            //Thread myB = new Thread(() =>
            //{
            //    threadtest.func("B:" + Thread.CurrentThread.ManagedThreadId.ToString());
            //    rsltB = threadtest.rslt;
            //});


            //cts.Token.Register(() =>
            //{
            //    Console.WriteLine("线程超时" + DateTime.Now.ToString("HHmmss"));
            //    myA.Abort();
            //    myA.Abort();
            //});

            //myA.Start();
            //myB.Start();

            //Console.WriteLine("线程并行" + DateTime.Now.ToString("HHmmss"));

            //Thread.Sleep(5000);
            //cts.Cancel();

            //myA.Join();
            //myB.Join();

            //Console.WriteLine("线程合并" + DateTime.Now.ToString("HHmmss"));

            //Console.WriteLine("Arslt:" + rsltA);
            //Console.WriteLine("Brslt:" + rsltB);

            #endregion

            #region 文件写入读取部分测试

            //string myError = "";

            //TextFileHelper myFile = TextFileHelper.CreateTextFileHelper("e:\\mytext.txt", out myError, System.IO.FileAccess.ReadWrite, Encoding.UTF8, false);

            //ResultInfo myResult = null;
            //myResult = myFile.OpenFile();
            //int myCount = 10 * 2000;
            //for (int i = 0; i < myCount; i++)
            //{
            //    myResult = myFile.Write(true, "第{0}条\t\t 切切切", i);
            //}

            //TextFileHelper myFiler1 = TextFileHelper.CreateTextFileHelper("e:\\mytext.txt", out myError, System.IO.FileAccess.Read, Encoding.UTF8);

            //myFiler1.OpenFile();
            //int myCountr1 = 10 * 2000;
            //for (int i = 0; i < myCountr1; i++)
            //{
            //    string myStr = string.Empty;
            //    myFiler1.ReadLine(out myStr);
            //    Console.WriteLine(myStr);
            //}

            //for (int i = myCount; i < (myCount + myCount); i++)
            //{
            //    myResult = myFile.Write(true, "第{0}条\t\t 啊啊啊啊啊啊啊啊", i);
            //}

            //myCountr1 = 10 * 4000;
            //for (int i = 0; i < myCountr1; i++)
            //{
            //    string myStr = string.Empty;
            //    myFiler1.ReadLine(out myStr);
            //    Console.WriteLine(myStr);
            //}
            //myFiler1.CloseFile();
            //myFile.CloseFile();

            #endregion

            Console.ReadKey();
        

        }


        


    }
}
